import {ref, computed, watch, onMounted,onUnmounted, nextTick} from 'vue'
import config from '@/config'

export function useLessonList() {
    const tableHeight = ref(0)
    const pageSize = ref(config.setting.pageSize)
    const loading = ref(true)
    const dataList = ref([])
    const total = ref(0)
    const pageIndex = ref(1)
    const tableListRef = ref(null)
    const cTableCardRef = ref(null)
    const actionBarRef = ref(null)


    const testData=[{
        seqid: '1',
        code: '2019000001',
        name: '张三',
        lesson: 'dataStructure',
        score: '90',
        credit: '3.0',
        gpa: '3.0',
        action: '删除'
    }]
    const columns=ref([
        {
            title: '序列值',
            key: 'seqid',
            sortable: true,
            minWidth: 100,
            align: 'center',
            fixed: 'left'
        },
        {
            title: '学号',
            key: 'code',
            align: 'center',
            className: 'main-color',
            minWidth: 180,
        },
        {
            title: '姓名',
            key: 'name',
            align: 'center',
            className: 'main-color',
            minWidth: 180,
        },
        {
            title: '课程',
            key: 'lesson',
            align: 'center',
            className: 'main-color',
            minWidth: 180,
        },
        {
            title: '成绩',
            key: 'score',
            align: 'center',
            className: 'main-color',
            minWidth: 180,
        },
        {
            title:'学分',
            key: 'credit',
            align: 'center',
            className: 'main-color',
            minWidth: 180,

        },
        {
            title:'绩点',
            key: 'gpa',
            align: 'center',
            className: 'main-color',
            minWidth: 180,
        },

        {
            title: '操作',
            key: 'action',
            align: 'center',
            slot:'action',
            className: 'main-color',
            minWidth: 100,
            fixed: 'right'
        }
    ])

    onMounted(()=>{
        getLessonList()
    })


    function getLessonList(){
        loading.value = true

        dataList.value = testData //列表数据
        total.value = parseInt(dataList.value.length) //列表长度
        loading.value = false
    }

    /**
     * 新增课程*/
    function addLesson(){

    }
    return {
        tableHeight,
        pageSize,
        loading,
        dataList,
        total,
        columns,
        pageIndex,
        tableListRef,
        cTableCardRef,
        actionBarRef,
        getLessonList,
        addLesson
    }
}